home *** CD-ROM | disk | FTP | other *** search
/ Plug-In Power Pack for Netscape Communicator / Plug-In Power Pack for Netscape Communicator.iso / plugins / dataviews / dvtools / demos / citydemo / c4i_wins.c < prev    next >
C/C++ Source or Header  |  1997-05-08  |  4KB  |  153 lines

  1. #ifndef lint
  2. static char SccsId[]= "@(#)c4i_wins.c    V1.13    3/13/95";
  3. #endif
  4.  
  5.  
  6. /*------------------------------------------------------------------
  7. | file name -- c4i_wins.c
  8. |
  9. | functions        Description
  10. | ---------        -----------
  11. | OpenWindow        Opens and displays the window.
  12. | CloseWin        Closes the window.
  13. | CleanupWindow        Cleans up the window views and drawports.
  14. |-----------------------------------------------------------------*/
  15.  
  16. #include "std.h"
  17. #include "dvstd.h"
  18. #include "dvtools.h"
  19. #include "VOstd.h"
  20. #include "Tfundecl.h"
  21. #include "c4i_vars.h"
  22. #include "c4i_fundecl.h"
  23.  
  24.  
  25.  
  26. /*-----------------------------------------------------------------
  27. |
  28. |  OpenWindow
  29. |       Performs the initialization needed for the opeing a window.
  30. |
  31. |    If the window is already visible return. Otherwise, create
  32. |    a window and display the appropriate view.
  33. |
  34. */
  35. OBJECT 
  36. OpenWindow (window_id)
  37.      int window_id;
  38. {
  39.   OBJECT screen = 0;
  40.   int error_code;
  41.   char buf[50];
  42.  
  43.   /* Only open the window if its not already opened. */
  44.   if (!DVscreen[window_id])
  45.     {
  46.  
  47.       /* Create the window */
  48.       if (WindowSize[window_id].x == -1)
  49.         /* use the default window size */
  50.  
  51.         screen = TscOpenSet (DeviceName, (CHAR *) NULL,
  52.                              V_WINDOW_X, WindowPos[window_id].x,
  53.                              V_WINDOW_Y, WindowPos[window_id].y,
  54.                              V_WINDOW_NAME, WindowName[window_id],
  55. #ifdef WINNT
  56.                  V_WIN32_ICON_NAME,      "cityicon",
  57. #ifdef DOUBLE_BUFFER
  58.                  V_WIN32_DOUBLE_BUFFER,  YES,
  59. #endif /* DOUBLE_BUFFER */
  60.  
  61. #else  /* Not WINNT */
  62.                  V_X_EXPOSURE_BLOCK,YES,
  63. #endif /* WINNT */
  64.                              V_INITIAL_CURSOR,
  65.                              V_END_OF_LIST);
  66.       else
  67.         screen = TscOpenSet (DeviceName, (CHAR *) NULL,
  68.                              V_WINDOW_WIDTH, WindowSize[window_id].x,
  69.                              V_WINDOW_HEIGHT, WindowSize[window_id].y,
  70.                              V_WINDOW_X, WindowPos[window_id].x,
  71.                              V_WINDOW_Y, WindowPos[window_id].y,
  72.                              V_WINDOW_NAME, WindowName[window_id],
  73. #ifdef WINNT
  74.                             V_WIN32_ICON_NAME,      "cityicon",
  75.  
  76. #ifdef DOUBLE_BUFFER
  77.                             V_WIN32_DOUBLE_BUFFER,  YES,
  78. #endif /* DOUBLE_BUFFER */
  79.  
  80. #else  /* Not WINNT */
  81.                       V_X_EXPOSURE_BLOCK,YES,
  82. #endif /* WINNT */
  83.                              V_INITIAL_CURSOR,
  84.                              V_END_OF_LIST);
  85.    if(!screen)
  86.  {
  87.    error_code=TscOpenError();
  88. #ifdef WINNT
  89.    sprintf(buf,"Product is not validated. Error code %d.",error_code);
  90.    MessageBox(NULL,buf,"Validation Error",MB_OK);
  91. #else
  92.    fprintf(stderr,"Product is not validated. Error code %d.",error_code);
  93. #endif
  94.    exit(error_code);
  95.   }
  96.  
  97.       /* Erase the "copyright" message and set the cursor */
  98.         (VOID) TscErase (screen);
  99.  
  100.       /* Setup generic service functions for common events */
  101.       InitSimpleEvents ();
  102.  
  103.       /* Keep a handle to the just opened screen */
  104.       DVscreen[window_id] = screen;
  105.     }
  106.  
  107.   return screen;
  108.  
  109. }                               /* END OpenWindow */
  110.  
  111.  
  112. /*-----------------------------------------------------------------
  113. |
  114. |   CloseWin
  115. |    Closes the  window and destoys its drawport
  116. */
  117. void 
  118. CloseWin (window_id)
  119.      int window_id;
  120. {
  121.   /* Drawports should've been destroyed with DP-Table. */
  122.  
  123.   /* Close the screen */
  124.   (VOID) TscClose (DVscreen[window_id]);
  125.   DVscreen[window_id] = 0;
  126. }
  127.  
  128.  
  129.  
  130. /*-----------------------------------------------------------------
  131. |
  132. |   CleanupWindow
  133. |    Cleans up Drawports, Viewports, and closes Screens.
  134. */
  135. void 
  136. CleanupWindow (window_id)
  137.      int window_id;
  138. {
  139.   /* Close the window if its open */
  140.   if (DVscreen[window_id])
  141.     {
  142.       /* Set the current screen */
  143.       (VOID) TscSetCurrentScreen (DVscreen[window_id]);
  144.  
  145.       /* Erase and Close the window */
  146.  
  147.       CloseWin( window_id );
  148.  
  149.  
  150.     }
  151. }
  152.  
  153.